<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>this</title>
</head>
<body>
    <button>dianwo</button>
    
</body>
<script>
    //1.在全局作用域中，this指向 window 对象
    console.log("全局作用域");  
    console.log('this=',this);
    function test(){
         //2.在普通函数作用域中，this也指向 window 对象 
        console.log("普通函数定义域");
        console.log('this =',this);
    }
    test();

    let zs = {
        name:'张三'
        show: function(){
            //3.在对象方法中，this指向：谁调用指向谁;
            console.log("对象方法中");            
            console.log('this =',this);
        }
    };
    zs.show();
    //4.在异步方法中（事件处理函数、时器回调函数），this指向window;
    let button = document.querySelector('button');
    button.addEventListener('click',e=>{
        console.log("事件处理方法中");
        console.log('this =',this);
    });
    setTimeout(()=>{
        console.log("定时器回调方法中");
        console.log();
        
        
    });
    
</script>
</html>